/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.isn.logueo.entity;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author pool
 */
@Entity
@Table(name = "tipo_usuario")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "TipoUsuario.findAll", query = "SELECT t FROM TipoUsuario t"),
    @NamedQuery(name = "TipoUsuario.findByCodTipoUsu", query = "SELECT t FROM TipoUsuario t WHERE t.codTipoUsu = :codTipoUsu"),
    @NamedQuery(name = "TipoUsuario.findByDescTipoUsu", query = "SELECT t FROM TipoUsuario t WHERE t.descTipoUsu = :descTipoUsu")})
public class TipoUsuario implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "Cod_Tipo_Usu", columnDefinition="CHAR(5) unsigned")
    private String codTipoUsu;
    @Column(name = "Desc_Tipo_Usu")
    private String descTipoUsu;
    @JoinTable(name = "detalle_tipousua_perfil", joinColumns = {
        @JoinColumn(name = "Cod_Tipo_Usu", referencedColumnName = "Cod_Tipo_Usu")}, inverseJoinColumns = {
        @JoinColumn(name = "Cod_Perfil", referencedColumnName = "Cod_Perfil")})
    @ManyToMany
    private Collection<Perfil> perfilCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "codTipoUsu")
    private Collection<PersonalAsistencial> personalAsistencialCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "codtipousu")
    private Collection<PersonalAdministrativo> personalAdministrativoCollection;

    public TipoUsuario() {
    }

    public TipoUsuario(String codTipoUsu) {
        this.codTipoUsu = codTipoUsu;
    }

    public String getCodTipoUsu() {
        return codTipoUsu;
    }

    public void setCodTipoUsu(String codTipoUsu) {
        this.codTipoUsu = codTipoUsu;
    }

    public String getDescTipoUsu() {
        return descTipoUsu;
    }

    public void setDescTipoUsu(String descTipoUsu) {
        this.descTipoUsu = descTipoUsu;
    }

    @XmlTransient
    public Collection<Perfil> getPerfilCollection() {
        return perfilCollection;
    }

    public void setPerfilCollection(Collection<Perfil> perfilCollection) {
        this.perfilCollection = perfilCollection;
    }

    @XmlTransient
    public Collection<PersonalAsistencial> getPersonalAsistencialCollection() {
        return personalAsistencialCollection;
    }

    public void setPersonalAsistencialCollection(Collection<PersonalAsistencial> personalAsistencialCollection) {
        this.personalAsistencialCollection = personalAsistencialCollection;
    }

    @XmlTransient
    public Collection<PersonalAdministrativo> getPersonalAdministrativoCollection() {
        return personalAdministrativoCollection;
    }

    public void setPersonalAdministrativoCollection(Collection<PersonalAdministrativo> personalAdministrativoCollection) {
        this.personalAdministrativoCollection = personalAdministrativoCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (codTipoUsu != null ? codTipoUsu.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof TipoUsuario)) {
            return false;
        }
        TipoUsuario other = (TipoUsuario) object;
        if ((this.codTipoUsu == null && other.codTipoUsu != null) || (this.codTipoUsu != null && !this.codTipoUsu.equals(other.codTipoUsu))) {
            return false;
        }
        return true;
    }
    
}
